<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">设置</block>
		</cu-custom>
		<view>
			<form>
				<view class="cu-form-group">
					<view class="title">姓名</view>
					<picker disabled>
						<view class="picker">
							{{personnel.username}}
						</view>
					</picker>
				</view>
				<view class="cu-form-group">
					<view class="title">手机号</view>
					<picker disabled>
						<view class="picker">
							{{mobile}}
						</view>
					</picker>
				</view>
				<view class="cu-form-group">
					<view class="title">部门</view>
					<picker disabled>
						<view class="picker">
							{{personnel.department_name}}
						</view>
					</picker>
				</view>

				<view class="cu-form-group">
					<view class="title">职位</view>
					<picker disabled>
						<view class="picker">
							{{personnel.type_name}}
						</view>
					</picker>
				</view>
				<view class="cu-form-group">
					<view class="title">工号</view>
					<picker disabled>
						<view class="picker">
							{{personnel.person_code}}
						</view>
					</picker>
				</view>
				<view class="cu-form-group">
					<view class="title">性别</view>
					<picker disabled>
						<view class="picker">
							{{gender}}
						</view>
					</picker>
				</view>

				<view class="cu-form-group">
					<view class="title">生日</view>
					<picker disabled>
						<view class="picker">
							{{personnel.birthday}}
						</view>
					</picker>
				</view>

				<view class="padding">
					<button class="cu-btn block bg-white margin-tb-sm lg" @click="gout()">退出登录</button>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				personnel: '',
				gender: '',
				mobile:''
			}
		},
		onLoad() {
			this.info();
		},

		methods: {
			PickerChange(e) {
				this.gender = e.detail.value
			},
			// 详情
			info: async function() {
				let result = await this.$api.checklogin({});
				//console.log('222', result)
				if (result.code == 1) {
					this.personnel = result.data.data;
					let sex = result.data.data.gender;
					let m = result.data.data.mobile;
					this.mobile = m.substr(0,3)+'****'+m.substr(7,11);
					if (sex == '0') {
						this.gender = '未设置';
					} else if (sex == '1') {
						this.gender = '男';
					} else if (sex == '2') {
						this.gender = '女';
					} else {
						this.gender = '未知';
					}
				} else {
					this.$common.errorToShow(result.msg);
				}
			},
			// 注销登录
			gout: async function() {
				let result = await this.$api.logout({});
				console.log(result)
				if (result.code == 1) {
					this.$common.successToShow(result.msg);
					setTimeout(() => {
						this.$db.del('userinfo');
						uni.hideToast();
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 1000)
				}
			}
		}
	}
</script>

<style>
</style>
